/**
*  \file kwptptx.h
*
*  \brief KWP2000 CAN Transmission Protocol
*
*  \author Michael J. Hohmann  michael.hohmann@linde-mh.de
*
*/
#ifndef KWPTPTX_H_INCLUDED
#define KWPTPTX_H_INCLUDED

/*================================================[ public includes  ]================================================*/
#include "../cfg/prj.h"
#include "../kwp/kwp_msg.h"
#include "../canmsg/canmsg.h"

/*================================================[ public defines   ]================================================*/

/*================================================[ public datatypes ]================================================*/


typedef void ( *kwptptx_transmit_func_t )( U8 *data );


/** Object definition.
* 
* The struct kwptptx_obj defines the attribute of an object.
*/
struct kwptptx_obj
{	
   kwptptx_transmit_func_t transmit;

   U8  separation_time;
   U32 separation_timer;

   U8  block_count;  /**< store value as received from flow control frame */

   BO  expect_flow_control;
   U8  sequence_number;
   U8 *p_read_buffer;
   U16 bytes_to_send;

   U32 flow_control_timer;
   U32 flow_control_timeout;
};

/*================================================[ public variables ]================================================*/

/*================================================[ inline functions ]================================================*/

/*================================================[ public functions ]================================================*/

/**
*  Constructor.
*
*  Construct an object. 
*
*  \param me Object pointer. NIL will throw an assert.
*
*  \return RC_SUCCESS if successful.
*/
RC kwptptx_construct( struct kwptptx_obj *me, kwptptx_transmit_func_t transmit_func );

BO kwptptx_start_transmission( struct kwptptx_obj *me, struct kwp_msg *p_msg );

BO kwptptx_cyclic_service( struct kwptptx_obj *me );

void kwptptx_process_msg( struct kwptptx_obj *me, U8 *data );
/*====================================================================================================================*/

#endif

/***********************************************************************************************************************
*                             Copyright 2020 Linde Material Handling. All rights reserved.                             *
***********************************************************************************************************************/
